<template>
  <div id="aa">
  <el-table
        :data="list"
        style="width: 100%">
        <el-table-column
          prop="orderNum"
          label="订单号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="refundReason"
          label="退款原因"
          width="180">
        </el-table-column>
        <el-table-column
          prop="refundPrice"
          label="退款金额"
          width="180">
        </el-table-column>
        <el-table-column
          prop="refundState"
          label="申请状态"
          width="180">
          <template slot-scope="scope">
            {{ scope.row.refundState==0?"申请退款":scope.row.refundState==1?"已同意":"已拒绝"}}
          </template>
        </el-table-column>
        <el-table-column
              label="操作"
              width="200">
             <template slot-scope="scope">
                <el-button  @click="agreeRefund(scope.row)" type="text" size="small">同意</el-button>
              </template>
            </el-table-column>
      </el-table>
      </div>
</template>

<script>
  export default{
    name:"Refund",
    data(){
      return{
      list:[]
      }
    },
    methods:{
      //管理员同意退款
      agreeRefund(obj){
        this.$http.post("order/yRefund/agreeRefund",obj).then(resp=>{
          alert(resp.data.mesg)
          this.loadAllRefund()
        })
      },
      //查询所有退款请求
      loadAllRefund(){
        this.$http.get("order/yRefund/loadAllRefund").then(resp=>{
          this.list=resp.data.data
          for(let l of this.list){
            if(l.applyState==0){
              l.applyState="退款申请中"
            }
            if(l.applyState==1){
              l.applyState="已同意"
            }
            if(l.applyState==2){
              l.applyState="已拒绝"
            }
          }
        })
      }
    },
    created(){
       this.loadAllRefund()
    }
  }
</script>

<style>
  #aa{
    margin-top: -150px;
  }
</style>
